package org.boulderfoodrescue.webapp.client.googlemap;

import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import com.google.gwt.maps.client.overlay.Marker;

public class MarkersList<T> {
	protected Map<T, Marker> markers = new HashMap<T, Marker>();
	public MarkersList(){
	}
	public void addMaker(T place, Marker marker){
		markers.put(place, marker);
	}
	public Marker getMarker(T place){
		return markers.get(place);
	}
	public Marker removeMarker(T place){
		Marker marker = getMarker(place);
		markers.remove(place);
		return marker;
	}
	public List<Marker> getAllMarkers()
	{
		List<Marker> list = new LinkedList<Marker>();
		Collection<Marker> c = markers.values();
		Iterator<Marker> itr = c.iterator();
		while(itr.hasNext())
			list.add(itr.next());
		return list;
	}
	public void removeAllMarkers()
	{
		markers.clear();
	}
}
